<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html; charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="/static/jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet" />

<script type="text/javascript" src="/static/jquery/jquery-1.11.1-min.js"></script>
<script type="text/javascript" src="/static/jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>
</head>
<script>
	jQuery(function ($) {
		$("#delValue").click(function () {
			var ids = $(":checkbox[name=valChk]:checked").map(function (value) {
				return this.value
			}).get().join(",");
			$.ajax({
				url:"/value/delValue.do",
				data:{ids:ids

				},
				success:function (data) {
					if(data>0){
						alert("删除成功！")
						location="/value/index.html";
					}else {
						alert("删除失败！")
					}
				}

			})
		})

		$("#editValueBtn").click(function () {
			
			var id =$(":checkbox[name=valChk]:checked")
				if (id.size() !=1){
					alert("请选择一项修改项！")
					return;
				}
				location="/value/editValue.do?id="+id.val();

		})
		
		$("#selectAll").click(function () {
			$(":checkbox[name=valChk]").prop("checked",this.checked)
		})

		$(":checkbox[name=valChk]").click(function () {
			$("#selectAll").prop("checked",$(":checkbox[name=valChk]").size()==$(":checkbox[name=valChk]:checked").size())
		})
	})
	


</script>
<body>

	<div>
		<div style="position: relative; left: 30px; top: -10px;">
			<div class="page-header">
				<h3>字典值列表</h3>
			</div>
		</div>
	</div>
	<div class="btn-toolbar" role="toolbar" style="background-color: #F7F7F7; height: 50px; position: relative;left: 30px;">
		<div class="btn-group" style="position: relative; top: 18%;">
		  <button type="button" class="btn btn-primary" onclick="location.href='/value/save.html'"><span class="glyphicon glyphicon-plus"></span> 创建</button>
		  <button type="button" class="btn btn-default" id="editValueBtn"><span class="glyphicon glyphicon-edit"></span> 编辑</button>
		  <button id="delValue" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-minus"></span> 删除</button>
		</div>
	</div>
	<div style="position: relative; left: 30px; top: 20px;">
		<table class="table table-hover">
			<thead>
				<tr style="color: #B3B3B3;">
					<td><input type="checkbox" id="selectAll" /></td>
					<td>序号</td>
					<td>字典值</td>
					<td>文本</td>
					<td>排序号</td>
					<td>字典类型编码</td>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${valueList}" var="u" varStatus="i">
					<tr class="active">
						<td><input type="checkbox" name="valChk" value="${u.id}" /></td>
						<td>${i.count}</td>
						<td>${u.value}</td>
						<td>${u.text}</td>
						<td>${u.orderNo}</td>
						<td>${u.type.name}</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>
	
</body>
</html>